#ifndef DATAGENDIALOG_H
#define DATAGENDIALOG_H

#include <QDialog>
#include <QSqlDatabase>
#include <QLineEdit>
#include <QSpinBox>
#include <QTableWidget>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QProgressBar>
#include "datagenerator.h"

class DataGenDialog : public QDialog
{
    Q_OBJECT

public:
    explicit DataGenDialog(const QSqlDatabase &db, QWidget *parent = nullptr);
    
private slots:
    void addColumn();
    void removeColumn();
    void generateData();
    void cancelGeneration();
    void onGenerationProgress(int percentage);
    void onGenerationFinished(const QString &message);
    void onGenerationError(const QString &error);

private:
    void setupUI();
    void updateUIState(bool generating);
    
    QSqlDatabase m_database;
    TableConfig m_tableConfig;
    
    // UI组件
    QLineEdit *m_tableNameEdit;
    QSpinBox *m_rowCountSpinBox;
    QTableWidget *m_columnsTable;
    QPushButton *m_addColumnButton;
    QPushButton *m_removeColumnButton;
    QPushButton *m_generateButton;
    QPushButton *m_cancelButton;
    QProgressBar *m_progressBar;
    QDialogButtonBox *m_buttonBox;
    
    DataGenerator *m_dataGenerator;
    bool m_generating;
};

#endif // DATAGENDIALOG_H